// app.js
App({
  globalData: {
    //  host: "http://192.168.0.14:48090/app-api/api",
    // 线上
    host: "http://121.37.178.3:48090/app-api/api",
    routerList: [{
        name: "同心门户",
        icon: "home-o",
        url: "/pages/index/index",
      },
      {
        name: "同心阵地",
        icon: "chat-o",
        url: "/pages/service/service",
      }, {
        name: "同心风采",
        icon: "chat-o",
        url: "/pages/service/service",
      }, {
        name: "个人中心",
        icon: "chat-o",
        url: "/pages/my/my",
      }
    ],
    unReadNum:0
  },
  // 缓存是否过期
  isExpiration() {
    // 当前时间
    var timestamp = Date.parse(new Date());
    //缓存中的过期时间
    var data_expiration = wx.getstoragesync("data_expiration");
    // 如果缓存中没有data expiration，说明也没有token，还未登录
    if (data_expiration) {
      //如果超时了，清除缓存，重新登录
      if (timestamp > data_expiration) {
        wx.clearstoragesync()
        return true;
      } else {
        return false
      }
    }
    return true
  },
  // getFont(){
  //   wx.loadFontFace({
  //     family: 'canger',
  //     source: 'url("https://example.com/iconfont.ttf")',
  //     success: function(res) {
  //       console.log('字体加载成功');
  //     },
  //     fail: function(res) {
  //       console.error('字体加载失败', res);
  //     }
  //   });
  // },
  onLaunch(options) {
    // this.isExpiration()
    // this.getFont()
    // 授权下载图片
    wx.getSetting({
      success(res) {
        if (!res.authSetting['scope.writePhotosAlbum']) {
          wx.authorize({
            scope: 'scope.writePhotosAlbum',
            success() {
              wx.showToast({
                title: '授权成功',
                icon: 'none'
              })
            }
          })
        }
      }
    })
  },towxml:require('/towxml/index'),

})